//
//  CWQ_userInfoHeadView.m
//  BaxTer
//
//  Created by 陈武琦 on 16/9/9.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "CWQ_userInfoHeadView.h"
#import "UIView+roundRect.h"
#import "UIButton+WebCache.h"
#import "UIImageView+BTimageView.h"
#import "UIButton+BTSetimage.h"
@implementation CWQ_userInfoHeadView

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.headBtn cwq_cornerRadius:34 borderColor:[UIColor whiteColor] borderWidth:1];
    self.trainCamp.layer.cornerRadius = 8;
    self.trainCamp.layer.masksToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
}

+ (instancetype)headView {
    
   CWQ_userInfoHeadView *view =  [[NSBundle mainBundle] loadNibNamed:@"CWQ_userInfoHeadView" owner:nil options:0].lastObject;
    return view;
}


- (void)setModel:(BTUserLevelM *)model {
    _model = model;
    [self.headBtn sd_setImageWithURL:[NSURL URLWithString:model.userImg] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"头像"]];
    self.userName.text = model.acName;
    self.proportion.text = [NSString stringWithFormat:@"%@",model.score];
    self.content.text = [NSString stringWithFormat:@"还差%@积分成为%@", model.disparityScore,model.soonLevelName];
    [self.trainCamp setTitle:model.levelName forState:UIControlStateNormal];
    
    [self.trainCampIcon bt_setImageWithUrl:model.levelIcon];
//    if ([model.levelName isEqualToString:@"训练营"]) {
//         [self.trainCampIcon setImage:[UIImage imageNamed:@"训练营-1"]];
//    }else {
//        [self.trainCampIcon setImage:[UIImage imageNamed:model.levelName]];
//    }
}


- (IBAction)headBtnClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(headView:clickHeadBtn:)]) {
        [_delegate headView:self clickHeadBtn:sender];
    }

    
}


- (IBAction)trainCampClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(headView:clickTrainCampBtn:)]) {
        [_delegate headView:self clickTrainCampBtn:sender];
    }
    

}
- (IBAction)integralClick:(id)sender {
    if ([_delegate respondsToSelector:@selector(headView:clickIntegralBtn:)]) {
        [_delegate headView:self clickIntegralBtn:sender];
    }
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
